﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Environmental.cs" company="Anton Frattaroli">
//   Copyright (c) Anton Frattaroli. All rights reserved.
// </copyright>
// <summary>
//   Defines the Environmental class.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Lidocaine
{
    using System;
    using System.Configuration;
    using System.Web;

    /// <summary>
    /// Defines the Environmental class.
    /// </summary>
    public static class Environmental
    {
        #region Fields
        /// <summary>
        /// Stores the database connection string for this application.
        /// </summary>
        private static string connectionString = ConfigurationManager.ConnectionStrings[((AppConfigSection)ConfigurationManager.GetSection("lidocaine/appConfig")).ConnectionStringName].ConnectionString;

        /// <summary>
        /// Stores the URL for the logon page.
        /// </summary>
        private static Uri logonUrl = ((AppConfigSection)ConfigurationManager.GetSection("lidocaine/appConfig")).LogOnUrl;

        /// <summary>
        /// Stores the URL for the error page.
        /// </summary>
        private static Uri errorUrl = ((AppConfigSection)ConfigurationManager.GetSection("lidocaine/appConfig")).ErrorUrl;

        /// <summary>
        /// Stores the title of the website.
        /// </summary>
        private static string title = ((AppConfigSection)ConfigurationManager.GetSection("lidocaine/appConfig")).Title;

        /// <summary>
        /// Stores the (host) domain of the website.
        /// </summary>
        private static string domain = ((AppConfigSection)ConfigurationManager.GetSection("lidocaine/appConfig")).Domain;

        /// <summary>
        /// Stores the path to the directory where static files are saved and served from.
        /// </summary>
        private static string staticFilesDirectory = HttpContext.Current.Server.MapPath("~/") + "Static_Files";

        /// <summary>
        /// Stores a boolean value indicating whether or not to use SSL.
        /// </summary>
        private static bool useSsl = ((AppConfigSection)ConfigurationManager.GetSection("lidocaine/appConfig")).UseSsl;

        /// <summary>
        /// Stores a boolean value indicating whether or not to allow setup.
        /// </summary>
        private static bool allowSetup = ((AppConfigSection)ConfigurationManager.GetSection("lidocaine/appConfig")).AllowSetup;
        #endregion

        #region Properties
        /// <summary>
        /// Gets the database connection string for the Lidocaine instance.
        /// </summary>
        public static string ConnectionString
        {
            get
            {
                return connectionString;
            }
        }

        /// <summary>
        /// Gets the URL for the logon page.
        /// </summary>
        public static Uri LogOnUrl
        {
            get
            {
                return logonUrl;
            }
        }
        
        /// <summary>
        /// Gets the URL for the error page.
        /// </summary>
        public static Uri ErrorUrl
        {
            get
            {
                return errorUrl;
            }
        }

        /// <summary>
        /// Gets the title of the website.
        /// </summary>
        public static string Title
        {
            get
            {
                return title;
            }
        }

        /// <summary>
        /// Gets the (host) domain of the website.
        /// </summary>
        public static string Domain
        {
            get
            {
                return domain;
            }
        }

        /// <summary>
        /// Gets the directory where static files are saved and served from.
        /// </summary>
        public static string StaticFilesDirectory
        {
            get
            {
                return staticFilesDirectory;
            }
        }

        /// <summary>
        /// Gets a value indicating whether or not to use SSL.
        /// </summary>
        public static bool UseSsl
        {
            get
            {
                return useSsl;
            }
        }

        /// <summary>
        /// Gets a value indicating whether or not to allow setup.
        /// </summary>
        public static bool AllowSetup
        {
            get
            {
                return allowSetup;
            }
        }
        #endregion
    }
}